//
//  DataStatisticsVC.m
//  massage
//
//  Created by 李志权 on 2017/1/4.
//  Copyright © 2017年 李志权. All rights reserved.
//

#import "DataStatisticsVC.h"

@interface DataStatisticsVC ()<UIScrollViewDelegate>
{
    UIScrollView *_scrollView;
}
@end

@implementation DataStatisticsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"数据统计";
    _scrollView = [[UIScrollView alloc]initWithFrame:self.view.bounds];
    [self.view addSubview:_scrollView];
    
    UIImageView *imageView = [UIImageView new];
    [imageView sd_setImageWithURL:[NSURL URLWithString:@"http://img30.360buyimg.com/mobilecms/s480x180_jfs/t1402/221/421883372/88115/8cc2231a/55815835N35a44559.jpg"] placeholderImage:[UIImage imageNamed:@""] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        image = [ImageCompress fixToFillScreenWithImage:image width:Width-40];
        
        
        UIScrollView *banner = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 20, Width, image.size.height+102)];
        banner.pagingEnabled = YES;
        banner.delegate = self;
        banner.showsVerticalScrollIndicator = NO;
        banner.contentSize = CGSizeMake(Width*10, 0);
        [_scrollView addSubview:banner];
        
        //圆点view
        UIView *dotView = [[UIView alloc]initWithFrame:CGRectMake(0, banner.YHighly-30, 15*10-7, 7)];
        dotView.X = Width/2-dotView.width/2;
        [_scrollView addSubview:dotView];
        
        for (int a = 0; a<10; a++) {
            UIImageView *picture = [[UIImageView alloc]initWithFrame:CGRectMake(a*Width+20, 0, image.size.width, image.size.height)];
            picture.image = image;
            [banner addSubview:picture];
            //标题
            UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(a*Width+30, picture.YHighly+10, Width-60, 14)];
            titleLabel.textColor = MAINBLUEGrayDark;
            titleLabel.font = fontSizeMinMin;
            titleLabel.text = @"标题";
            [Utils TakeHeight:titleLabel];
            [banner addSubview:titleLabel];
            //内容
            UILabel *content = [[UILabel alloc]initWithFrame:CGRectMake(titleLabel.X, titleLabel.YHighly+8, titleLabel.width, 24)];
            content.numberOfLines = 2;
            content.textColor = GrayLight;
            content.font = [UIFont systemFontOfSize:10];
            content.text = @"内容";
            [banner addSubview:content];
            
            UIView *dot = [[UIView alloc]initWithFrame:CGRectMake(15*a, 0, 7, 7)];
            [dot setShearRound:3.5 masksToBounds:YES borderWidth:0 borderColor:nil];
            dot.backgroundColor = GreenColor;
            dot.tag = 800+a;
            if (a >0) {
                dot.layer.borderColor = GrayLight.CGColor;
                dot.layer.borderWidth = 0.25;
                dot.backgroundColor = [UIColor whiteColor];
            }
            [dotView addSubview:dot];
        }
    }];


    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    int index = scrollView.contentOffset.x/scrollView.width;
    for (int a = 0; a<10; a++) {
        UIView *dot = [_scrollView viewWithTag:a+800];
        
        if (index == a) {
            dot.backgroundColor = GreenColor;
            dot.layer.borderWidth = 0;
            dot.layer.borderColor = [UIColor whiteColor].CGColor;
        }
        else
        {
            dot.backgroundColor = [UIColor whiteColor];
            dot.layer.borderWidth = 0.25;
            dot.layer.borderColor = GrayLight.CGColor;
        }
    }
}
@end
